package com.hulizuofang.wol.chat.client.view;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewImpl;
import com.hulizuofang.wol.chat.client.gin.ClientI18nMessages;
import com.hulizuofang.wol.chat.client.presenter.MainPagePresenter;
import com.hulizuofang.wol.chat.client.presenter.MainPagePresenter.PageView;

public class MainPageViewImpl extends ViewImpl implements PageView {

	private AbsolutePanel container;
	private AbsolutePanel contentPanel;

	@Inject
	public MainPageViewImpl(ClientI18nMessages i18n) {
		container = new AbsolutePanel();
		container.add(new Label(i18n.title()));

		contentPanel = new AbsolutePanel();
		container.add(contentPanel);
	}

	@Override
	public Widget asWidget() {
		return container;
	}

	@Override
	public void showLoading(boolean shouldLock) {
		//TODO create Loading visual lauching logic
	}

	@Override
	public void setInSlot(Object slot, Widget content) {
		if (slot == MainPagePresenter.TYPE_SetMainContent) {
			contentPanel.clear();

			if (content != null) {
				contentPanel.add(content);
			}
		} else {
			super.setInSlot(slot, content);
		}
	}

}
